<?php
class EM_Multidealpro_Helper_Price extends Mage_Core_Helper_Abstract
{
	public function backupSpecialPrice($model, $productId){
		$product = Mage::getModel('catalog/product')->load($productId);
		if($product->getId()){
			$specialPrice = $product->getSpecialPrice();
			$specialFromDate = $product->getSpecialFromDate();
			$specialToDate = $product->getSpecialToDate();
			$dealPrice = $model->getPrice();
			$dealDateFrom = date('m/d/Y H:i:s',$model->getDateFrom());
			$dealDateTo = date('m/d/Y H:i:s',$model->getDateTo());
			
			$model->setData('before_special_price',$specialPrice);
			$model->setData('before_special_price_date_from',$specialFromDate);
			$model->setData('before_special_price_date_to',$specialToDate);
			$model->save();
			
			$product->setData('special_price', $dealPrice);
			$product->setData('special_from_date', $dealDateFrom);
			$product->setData('special_to_date', $dealDateTo);
			$product->setSpecialFromDateIsFormated(true);
			$product->setSpecialToDateIsFormated(true);
			$product->save();
		}
	}
	
	public function restoreSpecialPrice($model, $productId){
		$product = Mage::getModel('catalog/product')->load($productId);
		if($product->getId()){
			$specialPrice = $model->getData('before_special_price');
			$specialFromDate = $model->getData('before_special_price_date_from');
			$specialToDate = $model->getData('before_special_price_date_to');

			$product->setData('special_price', $specialPrice);
			$product->setData('special_from_date', $specialFromDate);
			$product->setData('special_to_date', $specialToDate);
			$product->setSpecialFromDateIsFormated(true);
			$product->setSpecialToDateIsFormated(true);
			$product->save();
		}
	}
	
}